<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>角色主页</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<%@ include file="/WEB-INF/common.jsp"%>
<%@ page import="com.firefighting.entity.User" %>
<% User user = (User)request.getSession().getAttribute("currentUser"); %>
<link
	href="${path }/resources/css/plugins/bootstrap-table/bootstrap-table.min.css"
	rel="stylesheet">
<link href="${path }/resources/css/animate.css" rel="stylesheet">
<link href="${path }/resources/css/style.css?v=4.1.0" rel="stylesheet">

<!--dataTables css样式-->
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/jquery.dataTables.min.css">
<!--DataTables button扩展-->
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/buttons.dataTables.min.css">
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/form.css">
</head>
<style type="text/css" rel="stylesheet">
#province {
	width: 150px;
	margin-left: 20px;
	display: inline-block;
}

#city {
	width: 150px;
	margin-left: 20px;
	display: inline-block;
}

#district {
	width: 150px;
	margin-left: 20px;
	display: inline-block;
}
</style>
<body class="gray-bg" style="">
<jsp:include page="/WEB-INF/loginCheck.jsp" />
	<div>
		<h1 style="margin-left: 20px">修改密码</h1>
	</div>
	<!--添加的表单  -->
	<div id="" class="panel-body" style="margin-top: 30px" >
		<div data-parsley-validate class="form-horizontal form-label-left">
					<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">用户名：<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input value="${currentUser.username }" name="name" id = "name"
						class="form-control col-md-7 col-xs-12">
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="first-name">密码：<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input type="text" value="" name="password"
						class="form-control col-md-7 col-xs-12" id="pwd1">
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">确认密码：<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input type="text" value="" name="confirmPassword" 
						class="form-control col-md-7 col-xs-12" id="pwd2" onkeyup="validate()">
					<span id="tishi"></span>
				</div>
			</div>
			<div class="form-group">
				<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
					<button id="submit" type="submit" class="btn btn-success">提交</button>
					
				</div>
			</div>
		</div>

		

	</div>


	<!-- Peity-->
	<script src="${path }/resources/js/plugins/peity/jquery.peity.min.js"></script>

	<!-- Bootstrap table-->
	<script
		src="${path }/resources/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
	<script
		src="${path }/resources/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

	<!-- 自定义js-->
	<script src="${path }/resources/js/content.js?v=1.0.0"></script>

	<!-- jQuery Validation plugin javascript-->
	<script
		src="${path }/resources/js/plugins/validate/jquery.validate.min.js"></script>
	<script src="${path }/resources/js/plugins/validate/messages_zh.min.js"></script>

	<!-- jQuery form  -->
	<script src="${path }/resources/js/jquery.form.min.js"></script>

	<!-- layer javascript -->
	<script src="${path }/resources/js/plugins/layer/layer.min.js"></script>
	<!-- 省市联动 -->
	<script src="${path }/resources/js/distpicker.data.js"></script>
	<script src="${path }/resources/js/distpicker.js"></script>
	<script src="${path }/resources/js/main.js"></script>
    <!-- 表单验证 -->
    <script src="${path }/resources/js/jquery.min.js"></script>
    <script src="${path }/resources/js/jquery.validate.min.js"></script>

 <script>
 
 function validate() {
	 
     var pwd1 = document.getElementById("pwd1").value;
     var pwd2 = document.getElementById("pwd2").value;

     if(pwd1 == pwd2) {
         document.getElementById("tishi").innerHTML="<font color='green'>两次密码相同</font>";
         document.getElementById("submit").disabled = false;
     }
     else {
         document.getElementById("tishi").innerHTML="<font color='red'>两次密码不相同</font>";
       document.getElementById("submit").disabled = true;
     }
 }
 </script>
<script>

$("#submit").click(function(){
	var pwd1 = document.getElementById("pwd1").value;
	var pwd2 = document.getElementById("pwd2").value;
	var name = document.getElementById("name").value;
	
	$.ajax({
		url : "/firefighting/Enterprise/changePassword.htm",
		type : "POST",
		dataType : "json",
			data : {
			"password" : pwd1,
			"userName" : name, 
		},
		success : function(data)
		{
			var flag = data.flag;
			if(flag==true)
			alert("修改成功");
		},
		error : function(data) {
			alert("修改失败");
		}
	});
});
</script>

</body>
</html>